package com.wanxin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wanxin.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * The interface User mapper.
 *
 * @author common
 */
@Mapper
public interface UserMapper extends BaseMapper<User>{


    /**
     * 查询当前用户的权限信息
     *
     * @param uname the uname
     * @return the list
     */
    @Select("SELECT pinfo FROM t_power WHERE pid IN(SELECT pid FROM t_role_power WHERE rid IN(SELECT rid FROM t_user_role WHERE uid IN(SELECT id FROM t_user WHERE uname=#{uname})))")
    List<String> selectOnePrower(@Param("uname")String uname);


    /**
     * 查询当前用户的角色信息
     *
     * @param uname the uname
     * @return the list
     */
    @Select("SELECT rname FROM t_role WHERE rid IN(SELECT rid FROM t_user_role WHERE uid IN(SELECT id FROM t_user WHERE uname=#{uname}))")
    List<String> selectOneRole(String uname);
}

